
import Taro from '@tarojs/taro';
import { View, Text, Image } from "@tarojs/components";
import PropTypes from 'prop-types';
import './index.scss'

let app = Taro.getApp();
class recordDetails extends Taro.Component {
    static defaultProps = {
        recorditem: {},
        isnear: false,
        isRecycl: true
    };
    constructor(props) {
        super(props);
        this.state = {}
    }
    previewImage(picturesArr, item) {
        app.previewImage(picturesArr, item);
    }
    render() {
        let { isRecycl, recorditem } = this.props;
        if (recorditem.pics) {
            recorditem.picsArr = recorditem.pics.split('|')
        }else {
            recorditem.picsArr = []
        }
        return (
            <View className='record-details pl-3-5 pt-3-5 pr-4  ft26 bg_fff vo_h mb-2-5 bdr_10 pb-8-5 ov_h'>
                <View className=''>
                    <View className='fc_000 mb-4-5 flex flex-r flex-item-between'><Text>有效期：{recorditem.yxq}</Text> <Text className='fc_960'>状态：已使用</Text> </View>
                    <View className='fc_53C mb-2 flex flex-r flex-item-between ft_w600'>
                        <Text className='ft32'>药品名：{recorditem.drugname}</Text>
                    </View>
                    <View className='pr-5-6 mb-2'>
                        <Text>数量：{recorditem.usernum}支</Text>
                        {isRecycl &&<Text className='pl-9'>规格：{recorditem.standard}</Text>}
                    </View>
                    <View className='mb-2'> 批号：{recorditem.batch}</View>
                    <View className='mb-6-5'>提交时间：{recorditem.timesString}</View>
                    <View className='mb-2 fc_65C' >存放：{recorditem.wardname}</View>
                    <View className='mb-4-5 fc_65C'>所属科室：{recorditem.departmentname}</View> 
                    <View className='fc_FF8 mb-2'>领取人：{recorditem.getusername}</View>
                    <View className='mb-2 fc_FF8'>操作人：{recorditem.useusername }</View>
                    <View className='mb-2 fc_65C mb-4-5 word-all'>备注：{recorditem.mark}</View>
                    <View className='mb-4'>附件：{recorditem.picsArr.length}</View>
                    {recorditem.pics && <View className='record-picture flex flex-r'>
                        {
                            recorditem.picsArr.map((item) => {
                                return (
                                    <View key={item} className='imgs' onClick={() => { this.previewImage(recorditem.picsArr, item) }}>
                                        <Image className='pictures-img' mode='center' src={item}></Image>
                                    </View>
                                )
                            })
                        }
                    </View>
                    }
                </View>
            </View>
        );
    }
}

export default recordDetails;

recordDetails.propTypes = {
    recorditem: PropTypes.object,
    isnear: PropTypes.bool,
    isRecycl: PropTypes.bool
}